//package org.phoenixframework.api.teacher.config.mybatis;
//
//import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
//import org.apache.ibatis.reflection.MetaObject;
//import org.phoenixframework.api.teacher.util.SecurityUtils;
//import org.springframework.stereotype.Component;
//
//import java.time.LocalDateTime;
//
///**
// * Created by IntelliJ IDEA.
// *
// * @author doublelifeke
// * Email: hautxxxyzjk@163.com
// * DateTime: 2020/12/22 21:44
// * Description:
// */
//@Component
//public class MybatisPlusMetaObjectHandler implements MetaObjectHandler {
//
//    private final String createdBy = "createdBy";
//    private final String createdDate = "createdDate";
//    private final String lastModifiedBy = "lastModifiedBy";
//    private final String lastModifiedDate = "lastModifiedDate";
//
//    @Override
//    public void insertFill(MetaObject metaObject) {
//        if (metaObject.hasSetter(createdBy)) {
//            this.setFieldValByName(createdBy, SecurityUtils.getUserId(), metaObject);
//        }
//        if (metaObject.hasSetter(createdDate)) {
//            this.setFieldValByName(createdDate, LocalDateTime.now(), metaObject);
//        }
//        if (metaObject.hasSetter(lastModifiedBy)) {
//            this.setFieldValByName(lastModifiedBy, SecurityUtils.getUserId(), metaObject);
//        }
//        if (metaObject.hasSetter(lastModifiedDate)) {
//            this.setFieldValByName(lastModifiedDate, LocalDateTime.now(), metaObject);
//        }
//    }
//
//    @Override
//    public void updateFill(MetaObject metaObject) {
//        if (metaObject.hasSetter(lastModifiedBy)) {
//            this.setFieldValByName(lastModifiedBy, SecurityUtils.getUserId(), metaObject);
//        }
//        if (metaObject.hasSetter(lastModifiedDate)) {
//            this.setFieldValByName(lastModifiedDate, LocalDateTime.now(), metaObject);
//        }
//    }
//}
